package com.pubg.service.impl;

import com.pubg.dao.ProductDao;
import com.pubg.dao.impl.ProductDaoImpl;
import com.pubg.entity.Product;
import com.pubg.service.ProductService;

import java.util.Date;
import java.util.List;

/**
 * @描述  商品业务处理接口实现类
 * @Author WangYuanXiang
 * @Date 2019/4/26 14:50
 **/
public class ProductServiceImpl implements ProductService {
    private ProductDao productDao = new ProductDaoImpl();

    @Override
    public boolean add(Product product) {
        product.setCreateTime(new Date());
        return productDao.add(product)==1?true:false;
    }

    @Override
    public boolean del(int productId) {
        return productDao.del(productId)==1?true:false;
    }

    @Override
    public int getCount(String name) {
        return productDao.getCount(name);
    }

    @Override
    public List<Product> getPage(int currPageNo, int pageSize,String name) {
        return productDao.getPage(currPageNo,pageSize,name);

    }

    @Override
    public Product getOneProduct(int productId) {
        return productDao.getOneProduct(productId);
    }

    @Override
    public List<Product> findByName(String name) {
        return productDao.findByName(name);
    }

    @Override
    public List<Product> list() {
        return productDao.list();
    }
}
